function minCoinChange(coins, amount) {
    let result = Object.create(null);
    if (!amount) return result;

    const makeChange = (index, value, min) => {
        // coins [1, 5, 10, 25]
        let coin = coins[index];
        let newAmount = Math.floor(value / coin);
        // 如果剩余value值 除 硬币面值存在整数值，将min值对象重新赋值【value会一直减小，coin会增加】
        // 如果0，则不赋值，Math.floor(1 / 10)为0
        // if (newAmount) min[coin] = newAmount;
        if(newAmount) min[coin] = newAmount;
        // 51 % 1 === 0 不继续执行
        // 1 % 25 === 1 继续执行
        // 1 % 10 === 1 继续执行
        if (value % coin !== 0) {
            makeChange(--index, value - coin * newAmount, min);
        }
    };

    const arr = [];
    for (let i = 0; i < coins.length; i++) {
        // 循环遍历所有可选值，从最小面值开始
        const cache = {};
        makeChange(i, amount, cache);
        arr.push(cache);
    }

    console.log(arr);
    let newMin = 0;
    arr.forEach(item => {
        let min = 0;
        for (let v in item) min += item[v];
        if (!newMin || min < newMin) {
            newMin = min;
            result = item;
        }
    });

    return result;
}
const result = minCoinChange([1, 5, 10, 25], 51);
console.log(result);
